package test.ground.bfpp;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author wangshaopeng
 * @Date 2021/1/5
 */
@Configuration
public class Interceptor implements  WebMvcConfigurer {



    //全局过滤器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new In())
                //addPathPatterns 用于添加拦截规则
                .addPathPatterns("/**");
    }





    public static class In implements HandlerInterceptor {

        @Override
        public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//            String i = request.getParameter("i");
//            if(i==null){
//                return true;
//            }
//            return Boolean.parseBoolean(i);
            return true;
        }


    }




}
